//================v1要点总结===============
/**
 * 1. 尝试递归
 */
/**
 * Definition for singly-linked list.
 *  */

// eslint-disable-next-line no-unused-vars
function ListNode(val, next) {
    this.val = (val === undefined ? 0 : val)
    this.next = (next === undefined ? null : next)
}

/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var reverseList = function (head) {
    let rslt
    function reverse(node) {
        if (!node || !node.next) {
            rslt = node
            return node
        }
        let nextNode = reverse(node.next)
        nextNode.next = node
        return node
    }
    reverse(head)
    // 尾结点next赋空
    head && (head.next = null)
    return rslt
};

console.log(reverseList)